<?php
$this->Html->scriptBlock($scriptWindowMsg, array('inline' => false));
$this->Html->scriptBlock($scriptDate, array('inline' => false));
$this->Html->script(array('accountresumes'), false);
$formUrl = array('controller' => 'accountresumes', 'action' => 'add_manual');
echo $this->Form->create('Accountresume', array('url' => $formUrl, 'type' => 'text'));
?>
<div class="title-body-content"><?php echo $title_for_layout; ?><a class="checkfrm" rel="add"></a></div>
<div class="wrapper-form-account-resume clearfix">
    <div class="wrapper-date clearfix">
        <span class="size-span"><?php echo __('Date'); ?> :</span>
        <?php
        echo $this->Form->text('date', array(
            'class' => 'sel-date',
            'readonly' => 'readonly',
            'label' => false,
            'div' => false,)
        );
        ?> <label class="error-message">(*)</label>
    </div>
    <div class="wrapper-insurance-type-page4 clearfix">
        <span class="size-span"><?php echo __('Risk Origin'); ?> :</span>
        <?php
        echo $this->Form->input('Country.Country', array(
            'multiple' => false,
            'selected' => '',
            'empty' => true,
            'class' => 'size-sel1-page4',
            'label' => false,
            'div' => false,)
        );
        echo $this->Form->input('country', array(
            'type' => 'hidden',
            'value' => '',)
        );
        ?>
    </div>
    <div class="wrapper-reference-page4 clearfix">
        <span class="size-span"><?php echo __('Reference #'); ?> :</span>
        <?php
        echo $this->Form->input('refid_edit', array(
            'class' => 'inp-reference-page4 size-inp-reference',
            'label' => false,
            'div' => false,)
        );
        echo $this->Form->input('refid', array(
            'value' => strtoupper(uniqid('AIH-RESUME-')),
            'type' => 'hidden',)
        );
        ?>  <label class="error-message">(*)</label>
    </div>
    <div class="wrapper-producing-page4 clearfix">
        <table cellspacing="0" cellpadding="0" border="0">
            <tr>
                <td style="text-align:left; width:138px; vertical-align:top">
                    <span class="size-span"><?php echo __('Producer'); ?> :</span>
                </td>
                <td>
                    <?php
                    echo $this->Form->input('Producingbroker.Producingbroker', array(
                        'multiple' => false,
                        'empty' => false,
                        'class' => 'size-sel1-page4',
                        'label' => false,
                        'div' => false,)
                    );
                    ?>
                    <span id="Producingbroker"></span>
                </td>
                <td style="vertical-align:top">
                    <ul class="button-form-input">
                        <li><a href="JavaScript:void(0);" class="addContactField" rel="2">Add</a><!--<div class="space3">|</div>--></li>
                        <!--<li><a href="JavaScript:void(0);" class="openWin" rel="2">New</a></li>-->
                    </ul>
                </td>
            </tr>
        </table>
    </div>
    <div class="wrapper-rein-page4 clearfix">
        <table cellspacing="0" cellpadding="0" border="0">
            <tr>
                <td style="text-align:left; width:138px; vertical-align:top">
                    <span class="size-span"><?php echo __('Reinsured'); ?> :</span>
                </td>
                <td>
                    <?php
                    echo $this->Form->input('reinsured', array(
                        'class' => 'inp-reference-page4 size-inp-reference',
                        'label' => false,
                        'div' => false,)
                    );
                    ?>  <label class="error-message">(*)</label>
                </td>
            </tr>
        </table>
    </div>
    <div class="wrapper-ori-insurer-page4 clearfix">
        <table cellspacing="0" cellpadding="0" border="0">
            <tr>
                <td style="text-align:left; width:138px; vertical-align:top">
                    <span class="size-span"><?php echo __('Original Insured'); ?> :</span>
                </td>
                <td>
                    <?php
                    echo $this->Form->input('original_insured', array(
                        'class' => 'inp-reference-page4 size-inp-reference',
                        'label' => false,
                        'div' => false,)
                    );
                    ?> <label class="error-message">(*)</label>
                </td>
            </tr>
        </table>
    </div>
    <div class="wrapper-ori-insurer-page4 clearfix">
        <table cellspacing="0" cellpadding="0" border="0">
            <tr>
                <td style="text-align:left; width:138px; vertical-align:top">
                    <span class="size-span"><?php echo __('Markets'); ?> :</span>
                </td>
                <td>
                    <?php
                    echo $this->Form->input('Market.Market', array(
                        'multiple' => false,
                        'empty' => false,
                        'class' => 'size-sel1-page4',
                        'label' => false,
                        'div' => false,)
                    );
                    ?>
                    <span id="Market"></span>
                </td>
                <td style="vertical-align:top">
                    <ul class="button-form-input">
                        <li><a href="JavaScript:void(0);" class="addMarketField" rel="4">Add</a><!--<div class="space3">|</div>--></li>
                        <!--<li><a href="JavaScript:void(0);" class="openWinMarket" rel="4">New</a></li>-->
                    </ul>
                </td>
            </tr>
        </table>
    </div>
    <div class="wrapper-insurance-type-page4 clearfix">
        <span class="size-span"><?php echo __('Insurance Type'); ?> :</span>
        <?php
        echo $this->Form->input('Insurancetype.Insurancetype', array(
            'multiple' => false,
            'empty' => false,
            'class' => 'size-sel1-page4',
            'label' => false,
            'div' => false,)
        );
        ?>
    </div>
    <div class="wrapper-insurance-type-page4 clearfix">
        <span class="size-span"><?php echo __('Insurance Type Detail'); ?> :</span>
        <?php
        echo $this->Form->textarea('insurancetype_detail', array(
            'class' => 'aih-expense-textarea-from',
            'style' => 'width:41%; margin-left:0',
            'label' => false,
            'div' => false,)
        );
        ?>
    </div>
    
    <!-- new request -->
    <div class="wrapper-insurance-period-page4 clearfix">
        <span class="size-span"><?php echo __('Insurance Period'); ?> :</span>
        <?php
        echo $this->Form->text('from_date', array(
            'class' => 'sel-date',
            'readonly' => 'readonly',
            'label' => false,
            'div' => false,)
        );
        ?> <label class="error-message-first">(*)</label>
        <span class="sp-to"><?php echo __('To'); ?></span>
        <?php
        echo $this->Form->text('to_date', array(
            'class' => 'sel-date',
            'readonly' => 'readonly',
            'label' => false,
            'div' => false,)
        );
        ?>  <label class="error-message-second">(*)</label>
        <span class="sp-total-day">
            <?php
            echo $this->Form->input('total_days', array(
                'type' => 'hidden',)
            );
            ?>
            <?php echo __('Total day'); ?> : <span id="total_days"></span>
        </span>
    </div>
    <!-- end new request -->
    
    <!--
    <div class="wrapper-sum-insured-page4 clearfix">
        <span class="size-span"><?php echo __('Order Premium'); ?> :</span>
        <input type="text" id="OrderPremium" value="" class="inp-sum-insured" name="order_premium" style="width:350px" /> <label class="error-message">(*)</label>
        <?php
        echo $this->Form->input('Currency.Currency', array(
            'multiple' => false,
            'selected' => 3,
            'empty' => false,
            'label' => false,
            'div' => false,)
        );
        echo $this->Form->input('currency', array(
            'type' => 'hidden',
            'value' => 'IDR',)
        );
        echo $this->Form->input('order_premium', array(
            'type' => 'hidden',)
        );
        ?>
    </div>
    -->
    <div class="wrapper-sum-insured-page4 clearfix">
        <span class="size-span"><?php echo __('Sum Insured'); ?> :</span>
        <input type="text" id="SumInsured" value="" class="inp-sum-insured" name="sum_insured" style="width:350px" /> <label class="error-message">(*)</label>
        <?php
        echo $this->Form->input('Currency.Currency', array(
            'multiple' => false,
            'selected' => 3,
            'empty' => false,
            'label' => false,
            'div' => false,)
        );
        echo $this->Form->input('currency', array(
            'type' => 'hidden',
            'value' => 'IDR',)
        );
        echo $this->Form->input('sum_insured', array(
            'type' => 'hidden',)
        );
        ?>
    </div>
    
    <!-- new request -->
    <div class="wrapper-rate-page4 clearfix">
        <span class="size-span"><?php echo __('Rate'); ?> :</span>
        <?php
        echo $this->Form->text('rate', array(
            'class' => 'inp-rate',
            'label' => false,
            'div' => false,
            'title' => 'manual',)
        );
        ?> % <label class="error-message">(*)</label>
    </div>
    <div class="wrapper-gross-pre-page4 clearfix">
        <span class="size-span"><?php echo __('Gross Premium'); ?> :</span> 
        <input type="text" id="GrossPremium" title="manual" value="" class="inp-rate" name="gross_premium" /> <label class="error-message">(*)</label> <span class="selected_currency"></span>
        <?php
        echo $this->Form->text('gross_premium', array(
            'type' => 'hidden',)
        );
        ?> 
    </div>
    <div class="wrapper-rate-page4 clearfix">
        <span class="size-span"><?php echo __('Order Hereon'); ?> :</span>
        <?php
        echo $this->Form->text('order_hereon', array(
            'class' => 'inp-rate',
            'label' => false,
            'div' => false,
            'title' => 'manual',)
        );
        ?> % <label class="error-message">(*)</label>
    </div>
    <div class="wrapper-gross-pre-page4 clearfix">
        <span class="size-span"><?php echo __('Nett Premium'); ?> :</span> 
        <input type="text" id="NettPremium" title="manual" value="" class="inp-rate" name="nett_premium" /> <label class="error-message">(*)</label> <span class="selected_currency"></span>
        <?php
        echo $this->Form->text('nett_premium', array(
            'type' => 'hidden',)
        );
        ?>
    </div>
    <div class="wrapper-rate-page4 clearfix">
        <span class="size-span"><?php echo __('Client Discount'); ?> :</span>
        <?php
        echo $this->Form->text('client_discount', array(
            'class' => 'inp-rate',
            'label' => false,
            'div' => false,
            'title' => 'manual',)
        );
        ?> % <label class="error-message">(*)</label>
    </div>
    <div class="wrapper-gross-pre-page4 clearfix">
        <span class="size-span"><?php echo __('Order Premium'); ?> :</span>
        <input type="text" id="OrderPremium" title="manual" value="" class="inp-rate" name="order_premium" /> <label class="error-message">(*)</label> <span class="selected_currency"></span>
        <?php
        echo $this->Form->text('order_premium', array(
            'type' => 'hidden',)
        );
        ?>
    </div>
    <!-- end new request -->
    
    <div class="wrapper-payment-schedule clearfix">
        <span class="title-payment-schedule"><?php echo __('PAYMENT SCHEDULE'); ?></span>
        <div class="wrapper-content-payment-schedule clearfix">
            <table cellspacing="0" cellpadding="0" border="0" class="tbl-payment" style="margin-bottom:0">
                <tr class="tbl-payment-title">
                    <td class="td-from-producing-broker" style="text-align:left">
                        <?php echo __('FROM'); ?>
                        <select id="PaymentFromId" name="PaymentFrom" class="size-sel1-page4" style="width:120px"></select>
                        <a class="button-in-form addPaymentscheduleManualField" href="JavaScript:void(0);" style="margin-left: 35px"><?php echo __('Add'); ?></a>
                    </td>
                    <td class="td-aih-commission"><!--<?php echo __('AIH COMMISSION'); ?>--></td>
                </tr>
            </table>
            <span id="paymentscheduleField"></span>
        </div>
    </div>
</div>
<div class="wrapper-button-form">
    <div class="button-form">
        <div class="button-aihre button-blue"><a href="#" class="save">SAVE</a></div>
        <!--<div class="button-aihre button-blue"><a href="JavaScript:void(0)" class="save" onclick="document.getElementById('AccountresumeAdminAddManualForm').submit()">SAVE</a></div>-->
        <div class="button-aihre button-blue">
            <?php echo $this->Html->link(__('CANCEL'), array('plugin' => null, 'controller' => 'accountresumes', 'action' => 'index')); ?>
        </div>
    </div>
</div>
<?php
echo $this->Form->end();
$validForm = "
    $(function(){
        $('a.save').click(function(){
            var error = true;
            var pattern, pattern2;
            // Date
            if($('#AccountresumeDate').val()==''){
                $('#AccountresumeDate').parent().children('label.error-message').remove();
                $('#AccountresumeDate').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeDate').parent().children('label.error-message').remove();
            }
            // Reference # 
            if($('#AccountresumeRefidEdit').val()==''){
                $('#AccountresumeRefidEdit').parent().children('label.error-message').remove();
                $('#AccountresumeRefidEdit').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeRefidEdit').parent().children('label.error-message').remove();
            }
            // Reinsured
            if($('#AccountresumeReinsured').val()==''){
                $('#AccountresumeReinsured').parent().children('label.error-message').remove();
                $('#AccountresumeReinsured').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeReinsured').parent().children('label.error-message').remove();
            }
            // Original Insured
            if($('#AccountresumeOriginalInsured').val()==''){
                $('#AccountresumeOriginalInsured').parent().children('label.error-message').remove();
                $('#AccountresumeOriginalInsured').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeOriginalInsured').parent().children('label.error-message').remove();
            }
            
            // rechange
            // Sum Insured
            if($('#SumInsured').val()==''){
                $('#SumInsured').parent().children('label.error-message').remove();
                $('#SumInsured').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#SumInsured').val()*1 < 0) {
                $('#SumInsured').parent().children('label.error-message').remove();
                $('#SumInsured').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else {
                pattern = /^\\$?[1-9][0-9]{0,2}(,[0-9]{3})*(\.[0-9]{1,2})?$/.test($('#SumInsured').val());
                if(pattern){
                    $('#SumInsured').parent().children('label.error-message').remove();
                } else {
                    $('#SumInsured').parent().children('label.error-message').remove();
                    $('#SumInsured').after('<label class=\"error-message\">This field is invalid.</label>');
                    error = false;
                }
            }
            // Rate
            if($('#AccountresumeRate').val()==''){
                $('#AccountresumeRate').parent().children('label.error-message').remove();
                $('#AccountresumeRate').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#AccountresumeRate').val()*1 <= 0) {
                $('#AccountresumeRate').parent().children('label.error-message').remove();
                $('#AccountresumeRate').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else if($('#AccountresumeRate').val()*1 > 100) {
                $('#AccountresumeRate').parent().children('label.error-message').remove();
                $('#AccountresumeRate').after('<label class=\"error-message\">This value can\'t be greater than 100</label>');
                error = false;
            } else {
                pattern = /^[1-9]{1}[0-9]*(\.[0-9]+)?$/.test($('#AccountresumeRate').val());
                pattern2 = /^[0]{1}(\.[0-9]+)?$/.test($('#AccountresumeRate').val());
                if(pattern || pattern2){
                    $('#AccountresumeRate').parent().children('label.error-message').remove();
                } else {
                    $('#AccountresumeRate').parent().children('label.error-message').remove();
                    $('#AccountresumeRate').after('<label class=\"error-message\">This field is invalid</label>');
                    error = false;
                }
            }
            // Gross Premium
            if($('#GrossPremium').val()==''){
                $('#GrossPremium').parent().children('label.error-message').remove();
                $('#GrossPremium').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#GrossPremium').val()*1 < 0) {
                $('#GrossPremium').parent().children('label.error-message').remove();
                $('#GrossPremium').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else {
                pattern = /^\\$?[1-9][0-9]{0,2}(,[0-9]{3})*(\.[0-9]{1,2})?$/.test($('#GrossPremium').val());
                if(pattern){
                    $('#GrossPremium').parent().children('label.error-message').remove();
                } else {
                    $('#GrossPremium').parent().children('label.error-message').remove();
                    $('#GrossPremium').after('<label class=\"error-message\">This field is invalid.</label>');
                    error = false;
                }
            }
            // Order Hereon
            if($('#AccountresumeOrderHereon').val()==''){
                $('#AccountresumeOrderHereon').parent().children('label.error-message').remove();
                $('#AccountresumeOrderHereon').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#AccountresumeOrderHereon').val()*1 < 0) {
                $('#AccountresumeOrderHereon').parent().children('label.error-message').remove();
                $('#AccountresumeOrderHereon').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else if($('#AccountresumeOrderHereon').val()*1 > 100) {
                $('#AccountresumeOrderHereon').parent().children('label.error-message').remove();
                $('#AccountresumeOrderHereon').after('<label class=\"error-message\">This value can\'t be greater than 100</label>');
                error = false;
            } else {
                pattern = /^[1-9]{1}[0-9]*(\.[0-9]+)?$/.test($('#AccountresumeOrderHereon').val());
                pattern2 = /^[0]{1}(\.[0-9]+)?$/.test($('#AccountresumeOrderHereon').val());
                if(pattern || pattern2){
                    $('#AccountresumeOrderHereon').parent().children('label.error-message').remove();
                } else {
                    $('#AccountresumeOrderHereon').parent().children('label.error-message').remove();
                    $('#AccountresumeOrderHereon').after('<label class=\"error-message\">This field is invalid</label>');
                    error = false;
                }
            }
            // Nett Premium
            if($('#NettPremium').val()==''){
                $('#NettPremium').parent().children('label.error-message').remove();
                $('#NettPremium').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#NettPremium').val()*1 < 0) {
                $('#NettPremium').parent().children('label.error-message').remove();
                $('#NettPremium').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else {
                pattern = /^\\$?[1-9][0-9]{0,2}(,[0-9]{3})*(\.[0-9]{1,2})?$/.test($('#NettPremium').val());
                if(pattern){
                    $('#NettPremium').parent().children('label.error-message').remove();
                } else {
                    $('#NettPremium').parent().children('label.error-message').remove();
                    $('#NettPremium').after('<label class=\"error-message\">This field is invalid.</label>');
                    error = false;
                }
            }
            // Client Discount
            if($('#AccountresumeClientDiscount').val()==''){
                $('#AccountresumeClientDiscount').parent().children('label.error-message').remove();
                $('#AccountresumeClientDiscount').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#AccountresumeClientDiscount').val()*1 < 0) {
                $('#AccountresumeClientDiscount').parent().children('label.error-message').remove();
                $('#AccountresumeClientDiscount').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else if($('#AccountresumeClientDiscount').val()*1 == 0) {
                $('#AccountresumeClientDiscount').parent().children('label.error-message').remove();
                $('#AccountresumeClientDiscount').val(0);
            } else {
                pattern = /^[1-9]{1}[0-9]{0,1}(\.[0-9]+)?$/.test($('#AccountresumeClientDiscount').val());
                pattern2 = /^[0]{1}(\.[0-9]+)?$/.test($('#AccountresumeClientDiscount').val());
                if(pattern || pattern2){
                    $('#AccountresumeClientDiscount').parent().children('label.error-message').remove();
                } else {
                    $('#AccountresumeClientDiscount').parent().children('label.error-message').remove();
                    $('#AccountresumeClientDiscount').after('<label class=\"error-message\">This field is invalid</label>');
                    error = false;
                }
            }
            // end rechange

            // Order Premium
            if($('#OrderPremium').val()==''){
                $('#OrderPremium').parent().children('label.error-message').remove();
                $('#OrderPremium').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else if($('#OrderPremium').val()*1 < 0) {
                $('#OrderPremium').parent().children('label.error-message').remove();
                $('#OrderPremium').after('<label class=\"error-message\">This value can\'t be less than 0</label>');
                error = false;
            } else {
                pattern = /^[1-9][0-9]{0,2}(,[0-9]{3})*(\.[0-9]{1,2})?$/.test($('#OrderPremium').val());
                if(pattern){
                    $('#OrderPremium').parent().children('label.error-message').remove();
                } else {
                    $('#OrderPremium').parent().children('label.error-message').remove();
                    $('#OrderPremium').after('<label class=\"error-message\">This field is invalid.</label>');
                    error = false;
                }
            }
            
            // Brokerage
            $('input[title=\"required_date\"]').each(function(){
                if($(this).val()==''){
                    $(this).parent().children('label.error-message').remove();
                    $(this).after('<label style=\"display:block\" class=\"error-message\">This field is required</label>');
                    error = false;
                } else {
                    $(this).parent().children('label.error-message').remove();
                }
            });
            
            // change
            var arrID = new Array();
            var arr_broker_amount = new Array();
            var payment_amount = 0;
            var i = 0;
            $('input.payment_schedule_amount_manual').each(function(){
                var tmpID = $(this).attr('id');
                if(tmpID.indexOf('.') < 0)
                {
                    arr_broker_amount[i] = $(this).val().replace(/,/gi, '')*1;
                    payment_amount += $(this).val().replace(/,/gi, '')*1;
                    arrID[i] = tmpID.replace('broker_amount', '');
                    i++;
                }
            });
            
            var order_premium = $('#AccountresumeOrderPremium').val()*1;
            if(payment_amount!=order_premium) {
                $('#paymentscheduleField').parent().children('div.error-message').remove();
                $('#paymentscheduleField').before('<div class=\"error-message\">Payment must equal Order Premium</div>');
                error = false;
            } else {
                $('#paymentscheduleField').parent().children('div.error-message').remove();
            }
            
            var one_payment = 0;
            for(i = 0; i < arrID.length; i++) {
                one_payment = 0;
                $('input[name*=\"_'+arrID[i]+'\"]').each(function(){
                    one_payment += $(this).val().replace(/,/gi, '')*1;
                });
                //alert(arr_broker_amount[i]);
                //alert(one_payment);
                if(Accountresumes.roundNumber(arr_broker_amount[i]*2, 2) != Accountresumes.roundNumber(one_payment, 2)) {
                    $('#paymentscheduleField').parent().children('div.error-message').remove();
                    $('#paymentscheduleField').before('<div class=\"error-message\">Broker amount must equal total Market amount and AIH amount</div>');
                    error = false;
                }
            }
            
            if (error) {
                $('#AccountresumeAdminAddManualForm').submit();
            } else {
                if($('label[class*=\"error-message\"]').length > 0) {
                    $.scrollTo( 'label[class*=\"error-message\"]:eq(0)', 800 );
                } else {
                    $.scrollTo( 'div[class*=\"error-message\"]:eq(0)', 800 );
                }
            }
        });
        // Date
        $('#AccountresumeDate').change(function() {
            if($(this).val()==''){
                $(this).parent().children('label.error-message').remove();
                $(this).after('<label class=\"error-message\">This field is required</label>');
            } else {
                $(this).parent().children('label.error-message').remove();
            }
        }); 
        // Reference # 
        $('#AccountresumeRefidEdit').blur(function() {
            if($('#AccountresumeRefidEdit').val()==''){
                $('#AccountresumeRefidEdit').parent().children('label.error-message').remove();
                $('#AccountresumeRefidEdit').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeRefidEdit').parent().children('label.error-message').remove();
            }
        }); 
        // Reinsured
        $('#AccountresumeReinsured').blur(function() {
            if($('#AccountresumeReinsured').val()==''){
                $('#AccountresumeReinsured').parent().children('label.error-message').remove();
                $('#AccountresumeReinsured').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeReinsured').parent().children('label.error-message').remove();
            }
        }); 
        // Original Insured
        $('#AccountresumeOriginalInsured').blur(function() {
            if($('#AccountresumeOriginalInsured').val()==''){
                $('#AccountresumeOriginalInsured').parent().children('label.error-message').remove();
                $('#AccountresumeOriginalInsured').after('<label class=\"error-message\">This field is required</label>');
                error = false;
            } else {
                $('#AccountresumeOriginalInsured').parent().children('label.error-message').remove();
            }
        }); 
        // Brokerage
    });";
$this->Html->scriptBlock($validForm, array('inline' => false));
?>